package com.mgface.framework.jmx;

import org.springframework.jmx.export.annotation.ManagedAttribute;
import org.springframework.jmx.export.annotation.ManagedOperation;
import org.springframework.jmx.export.annotation.ManagedOperationParameter;
import org.springframework.jmx.export.annotation.ManagedOperationParameters;
import org.springframework.jmx.export.annotation.ManagedResource;
import org.springframework.stereotype.Component;

@Component
@ManagedResource(objectName = "bean:name=sbdev", description = "spring boot dev mbean")
public class SBDMBean {
	private String name;
	private int age;

	@ManagedAttribute(description = "name属性")
	public void setName(String name) {
		this.name = name;
	}

	@ManagedAttribute()
	public String getName() {
		return name;
	}

	public int getAge() {
		return age;
	}

	public void setAge(int age) {
		this.age = age;
	}

	@ManagedOperation(description = "添加2个数字")
	@ManagedOperationParameters({ @ManagedOperationParameter(name = "x", description = "第一个数字"),
			@ManagedOperationParameter(name = "y", description = "第二个数字") })
	public int add_1(int x, int y) {
		return x + y;
	}

	@ManagedOperation
	public int add_2(int x, int y) {
		return x + y;
	}

	public void dontExposeMe() {
		throw new RuntimeException();
	}
}
